package com.chester.quickstarter.service;

import com.alibaba.fastjson.JSONObject;
import com.chester.quickstarter.dao.domain.User;
import com.chester.quickstarter.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author chester7cheng
 */
@Service
@CacheConfig(cacheNames = "AccountService")
public class AccountService {
    @Autowired
    private UserMapper userMapper;

    @Cacheable(key = "'account_'+#id")
    public User findById(int id){
        User user = userMapper.findById(id);
        return user;
    }

    @Cacheable
    public JSONObject findUserBriefById(int id){
        JSONObject jsonObject = userMapper.findUserBriefById(id);
        return jsonObject;
    }
}
